package servlet;

import java.io.IOException;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import bean.weiboBean;
import pojo.Weibo;

/**
 * Servlet implementation class forwordsvl
 */
@WebServlet("/focusforwordsvl")
public class focusforwordsvl extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public focusforwordsvl() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		HttpSession session = request.getSession();
		weiboBean wb = new weiboBean();
		String   userid = request.getParameter("userid");
		String   weiboid =  request.getParameter("weiboid");
		//System.out.println(weiboid);
		//int weiboid = (int)request.getAttribute("weiboid");
		//ArrayList list = new ArrayList();
		//Weibo weibo = new Weibo();
		
		//list = wb.selectForwordWeibo(Integer.parseInt(weiboid));
		if(wb.insertforword(Integer.parseInt(userid), Integer.parseInt(weiboid))){	
			//session.setAttribute("forwordlist", list);
			//weibo = (Weibo) list.get(0);
			//session.setAttribute("forwordnickname",weibo.getNickname());
			request.getRequestDispatcher("indexsvl").forward(request, response);
		}else{			
			request.getRequestDispatcher("indexsvl").forward(request, response);
		}
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
